<template>

<!--    大学-->
  <div style="width: 100%;display: flex;justify-content: center">
    <div v-if="visible" style="width: 100%;display: flex;justify-content: center">
      <div class="big" v-if="uType=='university'">
        <div  class="base">
          <el-divider style="width: 95%;" content-position="left">
            <h3>基本信息</h3>
          </el-divider>
          <el-button
              v-if="$route.fullPath=='/setting/myArchives'"
              style="height: 30px;border-radius: 30%"
              size="mini"
          >编辑</el-button>
        </div>
        <div class="baseMsg">
          <div class="options">
            <p>登录名</p>
            <p>学校层次</p>
            <p>学校性质</p>
            <p>法人</p>
            <p>所在地</p>
            <p>注册时间</p>
          </div>
          <div class="msg">
            <p>{{university.universityName}}</p>
            <p>{{university.level}}</p>
            <p>{{university.nature}}</p>
            <p>{{university.legalPerson}}</p>
            <p>{{university.address}}</p>
            <p>{{university.registerTime  }}</p>
          </div>
        </div>
        <div class="contact">
          <el-divider style="width: 95%;" content-position="left">
            <h3>联系信息</h3>
          </el-divider>
        </div>
        <div class="contactMsg">
          <div class="options">
            <p>邮箱</p>

          </div>
          <div class="msg">
            <p>{{university.email}}</p>
          </div>
        </div>
      </div>

      <!--    企业-->
      <div class="big" v-else-if="uType=='company'">
        <div class="base">
          <el-divider style="width: 95%;" content-position="left">
            <h3>基本信息</h3>
          </el-divider>
          <el-button
              v-if="$route.fullPath=='/setting/myArchives'"
              style="height: 30px;border-radius: 30%"
              size="mini"
          >编辑</el-button>
        </div>
        <div class="baseMsg">
          <div class="options">
            <p>登录名</p>
            <p>企业法人</p>
            <p>企业地址</p>
            <p>注册时间</p>
          </div>
          <div class="msg">
            <p>{{company.companyName}}</p>
            <p>{{company.legalPerson}}</p>
            <p>{{company.address}}</p>
            <p>{{company.registerTime}}</p>
          </div>
        </div>
        <div class="contact">
          <el-divider style="width: 95%;" content-position="left">
            <h3>联系信息</h3>
          </el-divider>
        </div>
        <div class="contactMsg">
          <div class="options">
            <p>邮箱</p>
            <p>手机</p>
          </div>
          <div class="msg">
            <p>{{company.email}}</p>
            <p>{{company.tel||'未填写'}}</p>
          </div>
        </div>
      </div>

      <!--    学生-->
      <div class="big" v-else>
        <div class="base">
          <el-divider style="width: 95%;" content-position="left">
            <h3>基本信息</h3>
          </el-divider>
          <el-button
              v-if="$route.fullPath=='/setting/myArchives'"
              style="height: 30px;border-radius: 30%"
              size="mini"
          >编辑</el-button>
        </div>
        <div class="baseMsg">
          <div class="options">
            <p>登录名</p>
            <p>学校</p>
            <p>性别</p>
            <p>毕业年份</p>
            <p>地址</p>
          </div>
          <div class="msg">
            <p>{{student.studentName}}</p>
            <p>{{student.uid}}</p>
            <p>{{student.sex}}</p>
            <p>{{student.yearNum}}</p>
            <p>{{student.address}}</p>
          </div>
        </div>
        <div class="contact">
          <el-divider style="width: 95%;" content-position="left">
            <h3>联系信息</h3>
          </el-divider>
        </div>
        <div class="contactMsg">
          <div class="options">
            <p>邮箱</p>
            <p>手机</p>
          </div>
          <div class="msg">
            <p>{{student.email||'暂无'}}</p>
            <p>{{student.tel||'暂无'}}</p>
          </div>
        </div>
      </div>
    </div>
    <div v-else style="width: 70%;height:100px;background-color:#fff;display: flex;justify-content: center;align-items: center;height: 180px">
      <h3>该用户个人信息已隐藏~</h3>
    </div>

  </div>



</template>

<script>
import { getArchives} from "../../network/user";
export default {
  name: "archives",
  data() {
    return {
      uType:localStorage.getItem("userType"),
      formInline: {
        user: "",
        region: "",
      },
      company:{},
      university:{},
      student:{},
      visible:true
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      if(this.$route.fullPath.slice(0,6)=='/other'){
        setTimeout(()=>{
          let other=this.$store.state.other
          this.uType=other.type
          getArchives(other.type,other.uid)
              .then(res=>{
                console.log(res);
                if(this.uType=='university'){
                  this.university=res.data.extend.university
                  localStorage.setItem("dynamicName",this.university.universityName)
                  localStorage.setItem("dynamicVisible",this.university.visible)
                  if(this.university.archivesVisible==0){
                    this.visible=false
                  }
                  console.log(this.university)
                }else if(this.uType=='student'){
                  this.student=res.data.extend.student
                  localStorage.setItem("dynamicName",this.university.studentName)
                  localStorage.setItem("dynamicVisible",this.student.visible)
                  if(this.student.archivesVisible==0){
                    this.visible=false
                  }
                }else {
                  this.company=res.data.extend.company
                  localStorage.setItem("dynamicName",this.university.companyName)
                  localStorage.setItem("dynamicVisible",this.company.visible)
                  if(this.company.archivesVisible==0){
                    this.visible=false
                  }
                }
        })

        },0)
      }else {
        getArchives(
            localStorage.getItem("userType"),
            localStorage.getItem("userId"),
            true
        ).then((res) => {
          console.log(res);
          if(this.uType=='university'){
            this.university=res.data.extend.university
            console.log(this.university)
          }else if(this.uType=='student'){
            this.student=res.data.extend.student
          }else {
            this.company=res.data.extend.company
          }
        });
      }

    },
    onSubmit() {
      console.log("submit!");
    },
  },
};
</script>

<style scoped>
.big{
  width: 70%;
  box-sizing: border-box;
  padding: 2% 10%;
  display: flex;
  align-items: center;
  flex-direction: column;
  background-color: #fff;
  border-bottom: 1px solid grey;
}
.base {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.contact {
  width: 100%;
}
.baseMsg {
  width: 90%;
  font-size: 15px;
  color: rgb(128, 128, 128);
  display: flex;
  justify-content: space-between;
}
.contactMsg {
  width: 90%;
  height: 220px;
  font-size: 15px;
  color: rgb(128, 128, 128);
  display: flex;
  justify-content: space-between;
}
.options {
  width: 11%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.msg {
  color: black;
  width: 85%;
  display: flex;
  flex-direction: column;
}
</style>